#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''=================================================
@Project -> File   ：js逆向 -> 易车网
@IDE    ：PyCharm
@Author ：王启俊
@Date   ：2024-04-11 19:53
@Desc   ：
=================================================='''
import json
import time

import requests
import hashlib



if __name__ == '__main__':
    Id = input("请输入id:::")
    url = "https://mhapi.yiche.com/hcar/h_car/api/v1/param/get_param_details"
    timer = int(time.time() * 1000)
    params = {
        "cid": "508",
        "param": '{"cityId":"802","serialId":"%s"}'%Id
    }
    ha = hashlib.md5()
    param = params['param']
    print(param)
    ha.update((r'cid=508&param=%s19DDD1FBDFF065D3A4DA777D2D7A81EC' % param + str(
                       timer)).encode())
    sign = ha.hexdigest()

    headers = {
        # "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
        # "Cookie": f"CIGDCID=138ef0fb4d5b3563ba077b8540149501; G_CIGDCID=138ef0fb4d5b3563ba077b8540149501; auto_id=6c9a1f5383083317acf0cbb7b31e2605; CIGUID=d72dd00e-8071-4f38-8bb5-7ac93652ae0d; selectcity=469002; selectcityid=802; selectcityName=%E7%90%BC%E6%B5%B7; UserGuid=d72dd00e-8071-4f38-8bb5-7ac93652ae0d; csids=10628; isWebP=true; locatecity=469002; bitauto_ipregion=2409%3A8a5e%3Aa51%3Aefb0%3Ae1e2%3Ae1b2%3Ac20d%3Ad314%3A%E6%B5%B7%E5%8D%97%E7%9C%81%E7%90%BC%E6%B5%B7%E5%B8%82%3B802%2C%E7%90%BC%E6%B5%B7%E5%B8%82%2Cqionghai; pageCount=4; Hm_lvt_610fee5a506c80c9e1a46aa9a2de2e44=1712668351,1712836557; Hm_lpvt_610fee5a506c80c9e1a46aa9a2de2e44={int(time.time())}",
        "X-Sign": sign,
        "X-Timestamp": str(timer),
        "X-User-Guid": "d72dd00e-8071-4f38-8bb5-7ac93652ae0d",
        "X-Platform": "pc",
        # "X-Ip-Address": "2409:8a5e:a51:efb0:e1e2:e1b2:c20d:d314",
        # "X-City-Id": "802",
        # "Referer": "https://car.yiche.com/xiaomisu7/peizhi/",
        # "Cid": "508"

    }
    resu = requests.get(url, headers=headers,params=params)
    for i in resu.json().get('data').get('list'):
        print(i)
